# _*_ coding:utf-8 _*_
"""
:File: listing.py
:Author: cfp
:Date: 2025/9/9 16:08
:LastEditTime: 2025/9/9 16:08
:LastEditors: cfp
:Description:
"""

import datetime
from django.db import models


class AmazonListing(models.Model):
    listing_id = models.CharField(null=True, blank=True, verbose_name="Listing ID")
    seller_sku = models.CharField(verbose_name="卖家SKU")
    fnsku = models.CharField(null=True, verbose_name="FN SKU")
    item_name = models.CharField(null=True, verbose_name="商品名称")
    local_sku = models.CharField(verbose_name="本地SKU")
    local_name = models.CharField(verbose_name="本地名称")
    price = models.DecimalField(
        max_digits=10, decimal_places=2, null=True, blank=True, verbose_name="价格"
    )
    quantity = models.IntegerField(null=True, blank=True, verbose_name="数量")
    asin = models.CharField(null=True, blank=True, verbose_name="ASIN")
    parent_asin = models.CharField(null=True, blank=True, verbose_name="父ASIN")
    small_image_url = models.URLField(null=True, blank=True, verbose_name="小图片URL")
    status = models.IntegerField(null=True, blank=True, verbose_name="状态")
    is_delete = models.BooleanField(null=True, blank=True, verbose_name="是否删除")
    afn_fulfillable_quantity = models.IntegerField(
        null=True, blank=True, verbose_name="可发货数量"
    )
    reserved_fc_transfers = models.IntegerField(
        null=True, blank=True, verbose_name="预留转移数量"
    )
    reserved_fc_processing = models.IntegerField(
        null=True, blank=True, verbose_name="预留处理中数量"
    )
    reserved_customerorders = models.IntegerField(
        null=True, blank=True, verbose_name="预留客户订单数量"
    )
    afn_inbound_shipped_quantity = models.IntegerField(
        null=True, blank=True, verbose_name="已发货入库数量"
    )
    afn_unsellable_quantity = models.IntegerField(
        null=True, blank=True, verbose_name="不可销售数量"
    )
    afn_inbound_working_quantity = models.IntegerField(
        null=True, blank=True, verbose_name="入库处理中数量"
    )
    afn_inbound_receiving_quantity = models.IntegerField(
        null=True, blank=True, verbose_name="入库接收数量"
    )
    currency_code = models.CharField(null=True, blank=True, verbose_name="货币代码")
    landed_price = models.DecimalField(
        max_digits=10, decimal_places=2, null=True, blank=True, verbose_name="到岸价格"
    )
    listing_price = models.DecimalField(
        max_digits=10, decimal_places=2, null=True, blank=True, verbose_name="挂牌价格"
    )
    open_date = models.DateTimeField(null=True, blank=True, verbose_name="商品创建时间")
    listing_update_date = models.DateTimeField(
        null=True, blank=True, verbose_name="Listing更新时间"
    )
    seller_rank = models.IntegerField(null=True, blank=True, verbose_name="卖家排名")
    seller_category = models.JSONField(null=True, blank=True, verbose_name="卖家类别")
    review_num = models.IntegerField(null=True, blank=True, verbose_name="评论数量")
    last_star = models.FloatField(null=True, blank=True, verbose_name="最后星级评分")
    fulfillment_channel_type = models.CharField(
        null=True, blank=True, verbose_name="配送方式"
    )
    open_date_display = models.DateTimeField(
        null=True, blank=True, verbose_name="商品创建时间显示"
    )
    principal_info = models.JSONField(null=True, blank=True, verbose_name="负责人信息")
    shipping = models.DecimalField(
        max_digits=10, decimal_places=2, null=True, blank=True, verbose_name="运费"
    )
    points = models.IntegerField(null=True, blank=True, verbose_name="积分")
    sid = models.IntegerField(null=True, blank=True, verbose_name="SID")
    dimension_info = models.JSONField(null=True, blank=True, verbose_name="尺寸信息")
    pair_update_time = models.DateTimeField(
        null=True, blank=True, verbose_name="配对更新时间"
    )
    small_rank = models.JSONField(null=True, blank=True, verbose_name="小类排名信息")
    on_sale_time = models.DateTimeField(null=True, blank=True, verbose_name="开售时间")
    first_order_time = models.DateTimeField(
        null=True, blank=True, verbose_name="首单时间"
    )
    marketplace = models.CharField(null=True, blank=True, verbose_name="市场")
    seller_category_new = models.JSONField(
        null=True, blank=True, verbose_name="新卖家类别"
    )
    seller_brand = models.CharField(null=True, blank=True)
    global_tags = models.JSONField(null=True, blank=True, verbose_name="全局标签")
    extra_fields = models.JSONField(null=True, blank=True)

    class Meta:
        managed = False  # 不自动生成迁移
        unique_together = ["listing_id", "sid"]
        db_table = "asinking_amazonlisting"
        ordering = ["-id"]
